<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>
	  <div style="width: 800px;background: ;">
		<p>段落1</p>
		<p>段落2</p>
		<p>段落3</p>
		<p>段落4</p>
		<p>段落5</p>
		<p>段落6</p>
		<p>段落7</p>
		<p>段落8</p>
		<p>段落9</p>
		<p>段落10</p>
	  </div>
	  <script>
var ps = document.querySelectorAll('p');
		for(var i = 0; i < ps.length; i++) {
			ps[i].onmouseover = function() {	
				this.style.backgroundColor = 'red'
			};
			ps[i].index = i;
			ps[i].onmouseout = function(){
				if(this.index % 2 == 0) {
					this.style.backgroundColor = 'pink'
				}else {
					this.style.backgroundColor = ''
				}
			}		
			if(i % 2 == 0) {
				ps[i].style.backgroundColor = 'pink'
			}
		}
	  </script>
</body>
</html>